public class T {

}
class MyCircularQueue {

    public int[] elem;
    public int front;
    public int rear;

    public MyCircularQueue(int k) {
        elem = new int[k];
    }

    //入队操作
    public boolean enQueue(int value) {
        if(isFull()) {
            return false;
        }
        elem[rear] = value;
        rear = (rear+1) % elem.length;
        return true;
    }

//删除队头元素
    public boolean deQueue() {
        if (! isEmpty()) {
            front = (front + 1) % elem.length;
            return true;
        }
        return false;
    }
    //得到队头元素 不删除
    public int Front() {
        if (! isEmpty()) {
            return elem[front];
        }
        return -1;
    }

    //得到队尾元素 不删除
    public int Rear() {
        if (! isEmpty()) {
            return elem[( rear + elem.length - 1)%elem.length];
        }
       return -1;
    }

    //判空 front和rear相遇
    public boolean isEmpty() {
        if (front == rear) {
            return true;
        }
        return false;
    }

    public boolean isFull() {
        return (rear+1) % elem.length == front;
    }
}
